package com.baidu.health.service;

import com.baidu.health.pojo.TbCase;
import com.baidu.health.util.resFaqVo;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baidu.health.pojo.TbCaseContent;
import com.baidu.health.service.TbCaseContentService;
import com.baidu.health.mapper.TbCaseContentMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

/**
 *
 */
@Service
public class TbCaseContentServiceImpl extends ServiceImpl<TbCaseContentMapper, TbCaseContent>
    implements TbCaseContentService{

    @Autowired
    TbCaseContentMapper tbCaseContentMapper;


    @Override
    public List<TbCaseContent> selectlist() {
        List<TbCaseContent> list=tbCaseContentMapper.selectList(null);
        return list;
    }

//    @Override
//    public void caseContentAdd(TbCaseContent tbCaseContent) {
////        Date data=new Date();
////        SimpleDateFormat sdf=new SimpleDateFormat("yyy-MM-dd HH:mm:ss");
////        tbCaseContent.setStarttime(sdf.format(data));
//        tbCaseContent.setStarttime(new Date());
//        tbCaseContentMapper.insert(tbCaseContent);
//    }

    @Override
    public resFaqVo caseContentBycaseid(TbCaseContent tbCaseContentid) {
        List<TbCaseContent> caseContentBycaseidlist=tbCaseContentMapper.caseContentBycaseid(tbCaseContentid.getCaseid());
        return new resFaqVo(200, "成功", caseContentBycaseidlist);
    }

    @Override
    public resFaqVo caseContentDelete(TbCaseContent tbCaseContentd) {
        System.out.println("-------"+tbCaseContentd.getId());
        tbCaseContentMapper.caseContentDeleted(tbCaseContentd.getId());
        return new resFaqVo(200, "逻辑删除成功", null);
    }

    @Override
    public resFaqVo caseContentById(TbCaseContent tbCaseContentid) {
        List<TbCaseContent> list= tbCaseContentMapper.selectByid(tbCaseContentid.getId());
        return new resFaqVo(200, "成功", list);
    }

    @Override
    public resFaqVo lista() {
        List<TbCaseContent> list=tbCaseContentMapper.selectyd();
        return new resFaqVo(200, "cg", list);
    }

    @Override
    public resFaqVo listd() {
        List<TbCaseContent> list=tbCaseContentMapper.selectydd();
        return new resFaqVo(200, "cg", list);
    }

    @Override
    public resFaqVo listc() {
        List<TbCaseContent> list=tbCaseContentMapper.selectydc();
        return new resFaqVo(200, "cg", list);
    }

    @Override
    public resFaqVo listb() {
        List<TbCaseContent> list=tbCaseContentMapper.selectydb();
        return new resFaqVo(200, "cg", list);
    }

    @Override
    public resFaqVo caseContentAdd(TbCaseContent tbCaseContent) {
        tbCaseContent.setStarttime(new Date());
        tbCaseContentMapper.insert(tbCaseContent);
        return new resFaqVo(200, "添加成功", null);
    }

    @Override
    public resFaqVo ydpage(TbCaseContent tbCaseContentpage) {
        Page<TbCaseContent> page=new Page<>(tbCaseContentpage.getCurrent(),tbCaseContentpage.getPagesize());
        QueryWrapper<TbCaseContent> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("typeid", 1);
        queryWrapper.eq("deleted", 1);
        Page<TbCaseContent> page1=tbCaseContentMapper.selectPage(page,queryWrapper);
        return new resFaqVo(200, "成功", page1);
    }

    @Override
    public resFaqVo xxpage(TbCaseContent tbCaseContentpage) {
        Page<TbCaseContent> page=new Page<>(tbCaseContentpage.getCurrent(),tbCaseContentpage.getPagesize());
        QueryWrapper<TbCaseContent> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("typeid", 4);
        queryWrapper.eq("deleted", 1);
        Page<TbCaseContent> page1=tbCaseContentMapper.selectPage(page,queryWrapper);
        return new resFaqVo(200, "成功", page1);
    }

    @Override
    public resFaqVo sbpage(TbCaseContent tbCaseContentpage) {
        Page<TbCaseContent> page=new Page<>(tbCaseContentpage.getCurrent(),tbCaseContentpage.getPagesize());
        QueryWrapper<TbCaseContent> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("typeid", 3);
        queryWrapper.eq("deleted", 1);
        Page<TbCaseContent> page1=tbCaseContentMapper.selectPage(page,queryWrapper);
        return new resFaqVo(200, "成功", page1);
    }

    @Override
    public resFaqVo sppage(TbCaseContent tbCaseContentpage) {
        Page<TbCaseContent> page=new Page<>(tbCaseContentpage.getCurrent(),tbCaseContentpage.getPagesize());
        QueryWrapper<TbCaseContent> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("typeid", 2);
        queryWrapper.eq("deleted", 1);
        Page<TbCaseContent> page1=tbCaseContentMapper.selectPage(page,queryWrapper);
        return new resFaqVo(200, "成功", page1);
    }
}




